package org.example.dao.impl;

import cn.hutool.core.io.IoUtil;
import org.example.dao.UserDao;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;

@Repository //将当前类交给DIO容器管理
public class UserDaoimpl implements UserDao {
    public List<String> findAll()
    {
        //1.加载并读取user.txt文件，获取用户数据
        //InputStream in = new FileInputStream(new File("D:\\gitee远程代码仓库\\summer-camp\\web-project01\\springboot-web-01\\src\\main\\resources\\user.txt"));
        InputStream in = this.getClass().getClassLoader().getResourceAsStream("user.txt");
        ArrayList<String> lines = IoUtil.readLines(in, StandardCharsets.UTF_8,new ArrayList<>());
        return lines;
    }
}
